﻿using AMInstantMessagingServerDao;
using BaseDao;
using BaseSimpleAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UDPHelper;

namespace AMInstantMessagingServerAPI
{
    public class FriendController : BaseController<FriendModel, FriendEditModel, FriendViewModel>
    {
        private FriendService _FriendService = new FriendService();

        public override BaseService<FriendModel> Service => _FriendService;

        /// <summary>
        /// 获取全部的好友
        /// </summary>
        /// <returns></returns>
        public StatusData GetAllFriend()
        {
            var user_id = UserTools.GetUserId(UDPContext.Current.RequestUDPPackage);
            IEnumerable<FriendModel> friend_models = _FriendService.GetAllFriendByUserId(user_id);
            return StatusData<List<FriendViewModel>>.Success(friend_models.Select(n => TypeHelper.TryChangeType<FriendViewModel>(n)).ToList());
        }
    }
}
